﻿/*
 * 文件名称：
 * 程序员：huangsb
 * 创建时间：2008/05/10
 * 
 * 功能说明：上传配置
 * 
 * 修改人员：
 * 
 * 修改日期：
 * 
 * 修改记录：
 */

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Whir_System_Module_Config_UploadConfig : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        RoleHelper.IsLogin();    //登录判断

        if (!IsPostBack)
        {
            //string xmlPath = Server.MapPath(Whir.Common.Settings.GetString("XmlPath") + "UploadConfig.xml");
            string xmlPath = Server.MapPath("~/" + Whir.Common.Settings.GetString("XmlPath") + "UploadConfig.xml");

            Type type = typeof(Whir.Config.Model.UploadConfig);
            Whir.Config.Model.UploadConfig model = (Whir.Config.Model.UploadConfig)Whir.Common.XmlHelper.DeserializeObject(xmlPath, type);         //反序列化

            this.txtFolder.Text = model.folder;
            this.cbIsUploadEditor.Checked = (model.isUploadEditor == "1") ? true : false;
            this.cbIsUpdateName.Checked = (model.isUpdateName == "1") ? true : false;
            this.ddlSaveWay.SelectedValue = model.saveWay;
            this.txtAllowPicType.Text = model.allowPicType;
            this.txtMaxPicSize.Text = model.maxPicSize;
            this.txtAllowMediaType.Text = model.allowMediaType;
            this.txtMaxMediaSize.Text = model.maxMediaSize;
            this.txtAllowFileType.Text = model.allowFileType;
            this.txtMaxFileSize.Text = model.maxFileSize;
        }
    }

    //修改
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        Whir.Config.Model.UploadConfig model = new Whir.Config.Model.UploadConfig();

        model.folder = this.txtFolder.Text;
        model.isUploadEditor = (this.cbIsUploadEditor.Checked) ? "1" : "0";
        model.isUpdateName = (this.cbIsUpdateName.Checked) ? "1" : "0";
        model.saveWay = this.ddlSaveWay.SelectedValue;
        model.allowPicType = this.txtAllowPicType.Text;
        model.maxPicSize = this.txtMaxPicSize.Text;
        model.allowMediaType = this.txtAllowMediaType.Text;
        model.maxMediaSize = this.txtMaxMediaSize.Text;
        model.allowFileType = this.txtAllowFileType.Text;
        model.maxFileSize = this.txtMaxFileSize.Text;
  
        //string xmlPath = Server.MapPath(Whir.Common.Settings.GetString("XmlPath") + "UploadConfig.xml");
        string xmlPath = Server.MapPath("~/"+ Whir.Common.Settings.GetString("XmlPath") + "UploadConfig.xml");
        Type type = typeof(Whir.Config.Model.UploadConfig);
        Whir.Common.XmlHelper.SerializerObject(xmlPath, type, model);               //序列化

        this.OLAdd();    //操作日志
    }

    //操作日志
    protected void OLAdd()
    {
        Whir.Log.Model.Whir_OperateLog model = new Whir.Log.Model.Whir_OperateLog();
        model.title = "上传设置";
        model.operateType = 2;      //修改
        model.operateResult = true;
        model.operateDesc = "修改上传设置";

        Whir.Log.OperateLog.Add(model);
    }
}
